<?php

namespace App\Http\Controllers;

use App\Http\Model\User;
use Illuminate\Http\Request;

class CreateUserTokenController extends BaseController
{
    /**
     * 生成user_token
     *
     * Created at 2021/11/26 19:02
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @param Request $request
     * @throws \Exception
     */
    public function createUserToken(Request $request)
    {
        $userId = intval($request->input('user_id'));
        $model = new User();
        if (!$userId) {
            die();
        }

        $userInfo = $model->get_user($userId);
        if (!$userInfo) {
            die();
        }

        $model->set_current_user($userId);
        echo $model->getUserToken();
        die();
    }
}